/*******************************************************************************
 * Copyright (c) 2011 squid.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     squid - initial API and implementation
 ******************************************************************************/
package com.google.code.cubeirc.dialogs;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;

public class AlertBox {

	private MessageBox messagebox;

	//this is a hack to make it so MODIFY events on the file system don't cause two boxes to appear
	/** The alert visible. */
	private static boolean alertVisible=false;
	public AlertBox(Shell parent, String title, String message, int icon, int type){
		if (parent == null)
			parent = new Shell();
		
		messagebox = new MessageBox(parent, type|icon);		

		messagebox.setText(title);
		messagebox.setMessage(message);
	}
	public AlertBox(final Shell parent, final String title, final String message, final int icon){
		if(alertVisible) return;
		alertVisible = true;

		

		messagebox = new MessageBox(parent, SWT.OK|icon);

		messagebox.setText(title);
		messagebox.setMessage(message);

		if(messagebox.open() != 0) {
			alertVisible = false;
		}
		


	}

	public int go(){
		return messagebox.open();
	}
}
